package com.lantosec.hmrp.modules.revisit.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lantosec.hmrp.core.kit.PageVO;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.revisit.service.IRevisitTaskService;
import com.lantosec.hmrp.modules.revisit.vo.RevisitTaskVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * 回访任务 控制器
 *
 * @author AutoCode
 * @since 2020-04-28
 */
@Api(value = "回访任务控制器APP端", tags = "回访任务控制器APP端")
@RestController
@RequestMapping("/revisit/app/task")
@Log4j2
public class RevisitTaskController extends BaseController {
    @Autowired
    private IRevisitTaskService service;

    @GetMapping("all")
    @ApiOperation(value = "查询全部")
    public Result<List<RevisitTaskVO>> all(){
        return Result.ok(entity2VO(service.list()));
    }

    @GetMapping("getNoReturnVisit")
    @ApiOperation(value = "分页查询未回访")
    public Result<Page<RevisitTaskVO>> getNoReturnVisit(
            @ApiParam(value = "分页对象", required = true) PageVO<RevisitTaskVO> page,
            @ApiParam(name ="权限分类，1个人2科室3全员" ,value = "permissionsType")
            @RequestParam(name = "permissionsType",required = false) Integer permissionsType){
        service.getNoReturnVisit(page,permissionsType);
        return Result.ok(page);
    }

    @GetMapping("getReturnVisit")
    @ApiOperation(value = "分页查询已回访")
    public Result<Page<RevisitTaskVO>> getReturnVisit(@ApiParam(value = "分页对象", required = true) PageVO<RevisitTaskVO> page,
          @ApiParam(name ="权限分类，1个人2科室3全员" ,value = "permissionsType")
          @RequestParam(name = "permissionsType",required = false) Integer permissionsType){
        service.getReturnVisit(page,permissionsType);
        return Result.ok(page);
    }

    @GetMapping("getOvertimeReturnVisit")
    @ApiOperation(value = "分页查询超时回访")
    public Result<Page<RevisitTaskVO>> getOvertimeReturnVisit(@ApiParam(value = "分页对象", required = true) PageVO<RevisitTaskVO> page,
          @ApiParam(name ="权限分类，1个人2科室3全员" ,value = "permissionsType")
          @RequestParam(name = "permissionsType",required = false) Integer permissionsType){
        service.getOvertimeReturnVisit(page,permissionsType);
        return Result.ok(page);
    }

    @GetMapping("get/{id}")
    @ApiOperation(value = "主键查询")
    public Result<RevisitTaskVO> get(@ApiParam(value = "ID", required = true) @PathVariable(name="id") String id){
        return Result.ok(entity2VO(service.getById(id)));
    }

}
